#include "star/raystar.h"
#include "star/myraystaraction.h"
using namespace cocos2d;
//const 
RayStar::RayStar() 
    : center_pos_(0, 0) {
	char path[20];
	
	for (int i = 0; i < 5; i++) {
		sprintf(path,"star/%d.png",i%2);
		star_[i] = CCSprite::createWithSpriteFrameName(path);
		star_[i]->setScale(0.6f*(1-(i%3)/5.0));
		addChild(star_[i]);
	}
}

RayStar *RayStar::create() {
	RayStar *es = new RayStar;
	es->autorelease();
	return es;
}

void RayStar::StartRun(CCPoint pos,ccColor3B color) {
	center_pos_ = pos;
	for (int i = 0; i < 5; i++) {
		star_[i]->setVisible(false);
		star_[i]->stopAllActions();
		star_[i]->setColor(color);
		star_[i]->setPosition(pos);
		CCActionInterval *my_action = MyRayStarAction::create(center_pos_,i+1);
		star_[i]->runAction(CCSequence::create(my_action,CCCallFuncN::create(this,callfuncN_selector(RayStar::DoIt)),NULL));
		star_[i]->setVisible(true);
	}
}

void RayStar::DoIt(cocos2d::CCNode *node) {
	node->setVisible(false);
}